package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.Room;
import wiki.douzi.helpyougrow.mapper.RoomMapper;
import wiki.douzi.helpyougrow.service.RoomService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

/**
 * (Room)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:19
 */
@Service("roomService")
public class RoomServiceImpl implements RoomService {
    @Resource
    private RoomMapper roomMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<Room> queryAll() {
        return this.roomMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Room queryById(Integer id) {
        return this.roomMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param room 实例对象
     * @return 实例对象
     */
    @Override
    public Room insert(Room room) {
        this.roomMapper.insert(room);
        return room;
    }

    /**
     * 修改数据
     *
     * @param room 实例对象
     * @return 实例对象
     */
    @Override
    public Room update(Room room) {
        this.roomMapper.update(room);
        return this.queryById(room.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.roomMapper.deleteById(id) > 0;
    }

    @Override
    public List<Map<String, Object>> checkHotelOrder() {
        return this.roomMapper.checkHotelOrder();
    }
}

